/**
 * @file Utils.hpp
 *
 * @author Alejandro Dario Simi
 * @url http://www.daemonraco.com
 * @date 2011-12-03
 */

#ifndef __UTILS_HPP__
#define __UTILS_HPP__

#include <string>
using namespace std;


class Utils {
	protected:
		static Utils*	_Instance;

	protected:
		/**
		 * User Information
		 * @{
		 */
		bool	_hasUserInformation;

		string	_homeDirectory;
		string	_username;
		uid_t	_uid;
		/** @} */

	protected:
		Utils();

	public:
		~Utils();

	public:
		string cleanPath(const string &path);
		string homeDirectory();
		uid_t uid();
		string username();

	protected:
		bool hasUserInformation();
		void loadUserInformation();

	public:
		static Utils* Instance() {
			if(!Utils::_Instance) {
				Utils::_Instance = new Utils();
			}
			return Utils::_Instance;
		}

	public:
		static string CleanPath(const string &path) {
			return Utils::Instance()->cleanPath(path);
		}
		static string HomeDirectory() {
			return Utils::Instance()->homeDirectory();
		}
		static uid_t UID() {
			return Utils::Instance()->uid();
		}
		static string Username() {
			return Utils::Instance()->username();
		}
};

#endif /* __UTILS_HPP__ */
